oracle 中 "where sync.ad=agent1.ad(+)" 中的(+) 是啥意思啊?

来源:百度知道 编辑:UC知道 时间:2024/06/02 15:24:03
oracle 中

"... where sync.ad=agent1.ad(+) ..."

中的“(+)” 是啥意思啊?

这是外连接,(+)在的那一边和连接的方向相反

select * from sync, agent1 where sync.ad=agent1.ad(+)
就相当于sync和agent1左外连接
即select * from sync left join agent1 on sync.ad=agent1.ad

seelect * from sync, agent1 where sync.ad(+)=agent1.ad
就相当于sync和agent1右外连接
即select * from sync right join agent1 on sync.ad=agent1.ad

可以参考我以前回答的问题:http://zhidao.baidu.com/question/62981689.html

左连接,相当于
from sync left join on agent1 on sync.ad=agent1.ad

a.xxx=b.xxx(+)是仅当a.xxx = b.xxx时,取出b表中的值于a表中的值得进行左连接。
如:
1、a.xxx=b.xxx:a表与b表的xxx字段相等,条件为真,记录被选中。
2、a.xxx=b.xxx(+):a表与b表的xxx字段相等的记录被选中;b表有且a.表无(null)的记录也被选中。

b表中有的,a表中也有的用1
b表中有,a表中也有或空用2
例子:
a表 b表
f1 f2 f1 f2
1 a 1 a
2 b 2 b
4 c 3 c
5 d 4 d
5 e
where a.xxx=b.xxx: 4条记录
where a.xxx=b.xxx(+):5条记录。其中一条,选定的a表记录为空。